<?php
include '../connectBDD.php';

$id_event = $_GET['id_event'];
$query = "select * from comments where id_event = $id_event";
$result = mysql_query($query) or die(mysql_error());
$nb_res = mysql_num_rows($result);
echo "<div style='color:green;text-align:center;'>$nb_res commentaire(s) trouvé(s) trouvé(s)</div>";

if (mysql_num_rows($result) <= 0) {
    echo "<div class='no_result_found'>Aucun commentaire.</div>";
} else {
    echo "<div class='comments'>";
    while ($row = mysql_fetch_assoc($result)) {
        echo"
                         <div id='comment'>
                            <a class='croix_ferm' href=\"javascript:supprimerCommentaire('" . $row['id_comment'] . "', $id_event)\"><img src='../images/Close-32.png' height='17px' width='15px'/></a>
                                <div id='login_msg'>
                                    <a href='profil.php?login=" . $row['login'] . "'>" . $row['login'] . "</a>
                                     <span class='heure_msg'>" . $row['dateTime'] . "</span>
                                </div>
                                <div id='msg_content'>" . substr($row['comment'], 0, 100) . "</div>
                        </div>";
    }
}
?>
